package com.lq.schoolshop.controller.before;

import com.lq.schoolshop.bean.Result;
import com.lq.schoolshop.bean.StatusCode;
import com.lq.schoolshop.pojo.Expand.StoreAndGoods;
import com.lq.schoolshop.service.GoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author
 * @Date2021/1/8 19:21
 * @Version V1.0
 * 商品详情页功能
 **/
@Api(value = "商城前台功能--商品详情页模块",tags = "商城前台功能--商品详情页模块")
@CrossOrigin(origins = "*",maxAge = 3600)
@RequestMapping("productdetail")
@Controller
public class ForProductDetailController {

    @Autowired
    private GoodsService goodsService;

    //1.显示商品详情信息
    @ApiOperation(value = "显示商品详情信息",notes = "显示所有商品的详情信息")
    @ApiImplicitParam(name = "goodsid",value = "商品ID",dataType = "String",required = true,paramType = "query")
    @ResponseBody
    @RequestMapping(value = "/ShowProductById",method = RequestMethod.GET)
    public Result ShowProductById(@RequestParam("goodsid") int goodsid){
        Result result = null;
        StoreAndGoods storeAndGoods = goodsService.selByGidAndSidAll(goodsid);
        if(storeAndGoods!=null){
            result = new Result(true, StatusCode.OK,"根据ID显示商品信息和店铺信息成功",storeAndGoods);
        }else{
            result = new Result(false,StatusCode.RESOURCEINFOISNULL,"未查到相关的商品");
        }
        return result;
    }





}
